# - Try to find the GLIB2 libraries

if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES AND GTHREAD2_LIBRARIES AND GIO2_LIBRARIES AND GOBJECT2_LIBRARIES)
    # Already in cache, be silent
    set(GLIB2_FIND_QUIETLY TRUE)
endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES AND GTHREAD2_LIBRARIES AND GIO2_LIBRARIES AND GOBJECT2_LIBRARIES)

if (NOT WIN32)
   set(FPHSA_NAME_MISMATCHED 1)
   include(FindPkgConfig)
   pkg_search_module(PC_GLIB2 REQUIRED glib-2.0)
   pkg_search_module(PC_GTHREAD2 REQUIRED gthread-2.0)
   pkg_search_module(PC_GIO2 REQUIRED gio-2.0)
   pkg_search_module(PC_GOBJECT2 REQUIRED gobject-2.0)
   unset(FPHSA_NAME_MISMATCHED)
endif(NOT WIN32)

set(GLIB2_INCLUDE_DIR ${PC_GLIB2_INCLUDE_DIRS})

find_library(GLIB2_LIBRARIES NAMES glib-2.0 HINTS ${PC_GLIB2_LIBDIR} ${PC_GLIB2_LIBRARY_DIRS})

find_library(GTHREAD2_LIBRARIES NAMES gthread-2.0 HINTS ${PC_GTHREAD2_LIBDIR} ${PC_GTHREAD2_LIBRARY_DIRS})

find_library(GIO2_LIBRARIES NAMES gio-2.0 HINTS ${PC_GIO2_LIBDIR} ${PC_GIO2_LIBRARY_DIRS})

find_library(GOBJECT2_LIBRARIES NAMES gobject-2.0 HINTS ${PC_GOBJECT2_LIBDIR} ${PC_GOBJECT2_LIBRARY_DIRS})

mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES GTHREAD2_LIBRARIES GIO2_LIBRARIES GOBJECT2_LIBRARIES)
